package com.mingtu.guards.adapter;


import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingtu.guards.R;
import com.mingtu.guards.bean.TagBean;

import java.util.ArrayList;


/**
 * 描述：
 * 修改人：
 * 修改时间：
 * 修改备注：
 *
 * @author wkk
 */

public class PiechartValueAdapter extends BaseQuickAdapter<TagBean.ListBean, BaseViewHolder> {
    private Context context;
    private ArrayList<Integer> colors;

    public PiechartValueAdapter(Context context) {
        super(R.layout.item_piechat_value);
        this.context = context;
    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, TagBean.ListBean listBean) {
        String tag = listBean.getTag();
        TextView tvColor = helper.getView(R.id.tv_color);
        if (!StringUtils.isEmpty(tag)) {
            helper.setText(R.id.tv_value, tag);
        }
        if (colors != null) {
            GradientDrawable drawable = new GradientDrawable();
            drawable.setCornerRadius(4);
            drawable.setColor(colors.get(helper.getLayoutPosition()));
            tvColor.setBackgroundDrawable(drawable);
        }
    }

    public void setColors(ArrayList<Integer> colors) {
        this.colors = colors;
    }

}
